<?php
require(dirname(dirname(__FILE__))."/includes/initInterface.php");
require(dirname(dirname(__FILE__))."/includes/cls_mapModel.php");
require(dirname(dirname(__FILE__))."/includes/jssdk.php");
$action  = isset($_REQUEST['act']) ? trim($_REQUEST['act']) : 'getMapList';
$login  = new Map();
$login->$action();
Class Map {
	private $m;//自己的model
	private $jsonp;
	private $appid;
	private $secret;
	public function __construct(){
	
		$this->jsonp = new JSONP();
		//基础信息构建
		$this->m = new mapModel();
		//微信分享参数构建
	}
	
	public function getWxInfo(){
		global $_CODE;
		$host = isset($_GET['host'])?$_GET['host']:"";
		$res = $this->m->get_appid_ser();
		$this->appid=$res['appid'];
		$this->secret=$res['appsecret'];
		$jssdk = new JSSDK($this->appid, $this->secret);
		$signPackage = $jssdk->getSignPackage($host);
		die($this->jsonp->JSONP($_CODE['MAP_GETWXINFO_SUCCESS'],$signPackage));
		
	}
	
	public function getMapList(){
		global $_CODE;
		$result = $this->m->get_map_list();
		if($result){
			die($this->jsonp->JSONP($_CODE['MAP_GETMAPLIST_SUCCESS'],$result));
		}else{
			die($this->jsonp->JSONP($_CODE['MAP_GETMAPLIST_ERROR']));
		}
	}
	public function getMapListPage(){
		global $_CODE;
		$info['page'] = isset($_GET['page'])?intval($_GET['page']):1;
		$result = $this->m->get_map_list_page($info);
		if($result){
			die($this->jsonp->JSONP($_CODE['MAP_GETMAPLISTPAGE_SUCCESS'],$result));
		}else{
			die($this->jsonp->JSONP($_CODE['MAP_GETMAPLISTPAGE_ERROR']));
		}
	}
}